package com.ruoyi.web.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SuperShippingMethod;
import com.ruoyi.system.service.ISuperShippingMethodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 配送方式:记录物流或配送方式	Controller
 * 
 * @author ruoyi
 * @date 2025-08-13
 */
@RestController
@RequestMapping("/tool/shippingmethod")
public class SuperShippingMethodController extends BaseController
{
    @Autowired
    private ISuperShippingMethodService superShippingMethodService;

    /**
     * 查询配送方式:记录物流或配送方式	列表
     */
    @PreAuthorize("@ss.hasPermi('tool:shippingmethod:list')")
    @GetMapping("/list")
    public TableDataInfo list(SuperShippingMethod superShippingMethod)
    {
        startPage();
        List<SuperShippingMethod> list = superShippingMethodService.selectSuperShippingMethodList(superShippingMethod);
        return getDataTable(list);
    }

    /**
     * 导出配送方式:记录物流或配送方式	列表
     */
    @PreAuthorize("@ss.hasPermi('tool:shippingmethod:export')")
    @Log(title = "配送方式:记录物流或配送方式	", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SuperShippingMethod superShippingMethod)
    {
        List<SuperShippingMethod> list = superShippingMethodService.selectSuperShippingMethodList(superShippingMethod);
        ExcelUtil<SuperShippingMethod> util = new ExcelUtil<SuperShippingMethod>(SuperShippingMethod.class);
        util.exportExcel(response, list, "配送方式:记录物流或配送方式	数据");
    }

    /**
     * 获取配送方式:记录物流或配送方式	详细信息
     */
    @PreAuthorize("@ss.hasPermi('tool:shippingmethod:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(superShippingMethodService.selectSuperShippingMethodById(id));
    }

    /**
     * 新增配送方式:记录物流或配送方式	
     */
    @PreAuthorize("@ss.hasPermi('tool:shippingmethod:add')")
    @Log(title = "配送方式:记录物流或配送方式	", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SuperShippingMethod superShippingMethod)
    {
        return toAjax(superShippingMethodService.insertSuperShippingMethod(superShippingMethod));
    }

    /**
     * 修改配送方式:记录物流或配送方式	
     */
    @PreAuthorize("@ss.hasPermi('tool:shippingmethod:edit')")
    @Log(title = "配送方式:记录物流或配送方式	", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SuperShippingMethod superShippingMethod)
    {
        return toAjax(superShippingMethodService.updateSuperShippingMethod(superShippingMethod));
    }

    /**
     * 删除配送方式:记录物流或配送方式	
     */
    @PreAuthorize("@ss.hasPermi('tool:shippingmethod:remove')")
    @Log(title = "配送方式:记录物流或配送方式	", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(superShippingMethodService.deleteSuperShippingMethodByIds(ids));
    }
}
